package com.xbongbong.paas.controller;

import com.alibaba.fastjson.JSON;
import com.xbongbong.paas.pojo.dto.PermissionAppDetailDTO;
import com.xbongbong.paas.pojo.dto.PermissionModuleDetailDTO;
import com.xbongbong.paas.pojo.dto.RoleBatchAddDTO;
import com.xbongbong.paas.pojo.dto.RoleBatchDelDTO;
import com.xbongbong.paas.pojo.dto.UserAddRoleDTO;
import com.xbongbong.paas.pojo.dto.UserDelRoleDTO;
import com.xbongbong.paas.pojo.dto.UserDetailDTO;
import com.xbongbong.paas.pojo.dto.UserGetDTO;
import com.xbongbong.paas.pojo.dto.UserInfoDTO;
import com.xbongbong.paas.pojo.dto.UserListDTO;
import com.xbongbong.paas.pojo.vo.RoleAppDetailVO;
import com.xbongbong.paas.pojo.vo.RoleBatchAddVO;
import com.xbongbong.paas.pojo.vo.RoleBatchDelVO;
import com.xbongbong.paas.pojo.vo.RoleModuleDetailVO;
import com.xbongbong.paas.pojo.vo.UserAddRoleVO;
import com.xbongbong.paas.pojo.vo.UserDelRoleVO;
import com.xbongbong.paas.pojo.vo.UserDetailVO;
import com.xbongbong.paas.pojo.vo.UserGetVO;
import com.xbongbong.paas.pojo.vo.UserInfoVO;
import com.xbongbong.paas.pojo.vo.UserListVO;
import com.xbongbong.paas.pojo.vo.UserMembersVO;
import com.xbongbong.paas.service.UserService;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.BaseVO;
import com.xbongbong.paas.toolbox.wrap.XbbResponse;
import com.xbongbong.pro.constant.XbbProConstant;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.user.pojo.dto.UserAssistAddDTO;
import com.xbongbong.pro.user.pojo.dto.UserAssistDelDTO;
import com.xbongbong.pro.user.pojo.dto.UserAssistUpdateDTO;
import com.xbongbong.pro.user.pojo.dto.UserGetDataPermissionDTO;
import com.xbongbong.pro.user.pojo.dto.UserLetterListDTO;
import com.xbongbong.pro.user.pojo.dto.UserMaxDataPermissionDTO;
import com.xbongbong.pro.user.pojo.dto.UserMembersAddDTO;
import com.xbongbong.pro.user.pojo.dto.UserMembersGetDTO;
import com.xbongbong.pro.user.pojo.dto.WorkHandoverInfoDTO;
import com.xbongbong.pro.user.pojo.dto.WorkHandoverSaveDTO;
import com.xbongbong.pro.user.pojo.vo.UserAssistAddVO;
import com.xbongbong.pro.user.pojo.vo.UserAssistDelVO;
import com.xbongbong.pro.user.pojo.vo.UserGetDataPermissionVO;
import com.xbongbong.pro.user.pojo.vo.UserLetterListVO;
import com.xbongbong.pro.user.pojo.vo.UserMaxDataPermissionVO;
import com.xbongbong.pro.user.pojo.vo.WorkHandoverInfoVO;
import com.xbongbong.pro.user.pojo.vo.WorkHandoverSaveVO;
import com.xbongbong.pro.user.pojo.vo.WorkHandoverStatusVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Objects;

/**
 * 用户相关接口
 * @author kaka
 * @time 2018-8-28
 */
@RestController
@RequestMapping(value = XbbProConstant.API_ROOT_PREFIX + "/user")
public class UserController {

    private static  final Logger LOG = LoggerFactory.getLogger(UserController.class);

    @Resource
    private UserService userService;

    /**
     * 获取登录用户信息接口
     * @param userInfoDTO 关联DTO
     */
    @RequestMapping(value = "/info", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public String info(@RequestBody @Valid UserInfoDTO userInfoDTO, BindingResult br) throws Exception {
        XbbResponse<UserInfoVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserInfoVO userInfoVO = userService.getUserInfo(userInfoDTO);
                response = new XbbResponse<>(userInfoVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 获取用户信息(非登录用户的)
     *
     */
    @RequestMapping(value = "/info/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getUserInfo(@RequestBody @Valid UserGetDTO userGetDTO, BindingResult br) throws Exception {
        XbbResponse<UserGetVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserGetVO userGetVO = userService.getUserInfoByTargetUserId(userGetDTO);
                response = new XbbResponse<>(userGetVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }
    /**
     * 获取用户列表
     * @param userListDTO 关联DTO
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String list(@RequestBody @Valid UserListDTO userListDTO, BindingResult br) {
        XbbResponse<UserListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            //请求参数后处理，比如trim
            userListDTO.postProcess();
            try {
                UserListVO userListVO = userService.list(userListDTO);
                response = new XbbResponse<>(userListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 获取组织架构用户详情
     * @param userDetailDTO 关联DTO
     */
    @RequestMapping(value = "/detail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String detail(@RequestBody @Valid UserDetailDTO userDetailDTO, BindingResult br) {
        XbbResponse<UserDetailVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserDetailVO userDetailVO = userService.detail(userDetailDTO);
                response = new XbbResponse<>(userDetailVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 已删除人员的查询
     * @param userListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/getDisableUser/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getDisableUserList(@RequestBody @Valid UserListDTO userListDTO, BindingResult br) {
        XbbResponse<UserListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            //请求参数后处理，比如trim
            userListDTO.postProcess();
            try {
                UserListVO userListVO = userService.getDisableUserList(userListDTO);
                response = new XbbResponse<>(userListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 批量删除用户角色,有以下规则
     * 1.员工角色只有1个不删除
     * 2.员工删除角色在原角色中没有不删除
     * 3.超级管理员角色不能删除
     * @param roleBatchDelDTO 关联DTO
     */
    @RequestMapping(value = "/roleBatchDel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String roleBatchDel(@RequestBody @Valid RoleBatchDelDTO roleBatchDelDTO, BindingResult br) {
        XbbResponse<RoleBatchDelVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                RoleBatchDelVO batchDelVO = userService.roleBatchDel(roleBatchDelDTO);
                response = new XbbResponse<>(batchDelVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 批量给用户增加角色
     * 1.员工角色大于5个不添加
     * 2.员工添加角色与原角色相同不添加
     * @param roleBatchAddDTO 关联DTO
     */
    @RequestMapping(value = "/roleBatchAdd", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String roleBatchAdd(@RequestBody @Valid RoleBatchAddDTO roleBatchAddDTO, BindingResult br) {
        XbbResponse<RoleBatchAddVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                RoleBatchAddVO batchAddVO = userService.roleBatchAdd(roleBatchAddDTO);
                response = new XbbResponse<>(batchAddVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 给员工分配角色
     * @param addRoleDTO 关联DTO
     */
    @RequestMapping(value = "/addRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String addRole(@RequestBody @Valid UserAddRoleDTO addRoleDTO, BindingResult br) {
        XbbResponse<UserAddRoleVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserAddRoleVO editRoleVO = userService.addRole(addRoleDTO);
                response = new XbbResponse<>(editRoleVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 删除员工的某一个角色
     * @param delRoleDTO 关联DTO
     */
    @RequestMapping(value = "/delRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String delRole(@RequestBody @Valid UserDelRoleDTO delRoleDTO, BindingResult br) {
        XbbResponse<UserDelRoleVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserDelRoleVO editRoleVO = userService.delRole(delRoleDTO);
                response = new XbbResponse<>(editRoleVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 获取员工最大数据权限
     * 为2或3时同时返回主管的部门
     * 为4时，即最高数据权限为自定义，则返回助理的部门的员工
     */
    @RequestMapping(value = "/maxDataPermission", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String maxDataPermission(@RequestBody @Valid UserMaxDataPermissionDTO maxDataPermissionDTO, BindingResult br) {
        XbbResponse<UserMaxDataPermissionVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserMaxDataPermissionVO maxDataPermissionVO = userService.maxDataPermission(maxDataPermissionDTO);
                response = new XbbResponse<>(maxDataPermissionVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            } catch (IllegalAccessException | InstantiationException e) {
                LOG.error("/user/maxDataPermission 捕获异常", e);
                response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100001);
            }
        }
        return JSON.toJSONString(response);
    }


    /**
     * Description: 设置角色获取自定义数据权限的设置
     * @param userGetDataPermissionDTO
     * @param br
     * @return java.lang.String
     * @author 魏荣杰
     * @date 2020/6/3 8:37 下午
     */
    @RequestMapping(value = "/getDataPermission", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getDataPermission(@RequestBody @Valid UserGetDataPermissionDTO userGetDataPermissionDTO, BindingResult br) {
        XbbResponse<UserGetDataPermissionVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserGetDataPermissionVO userGetDataPermissionVO = userService.getDataPermission(userGetDataPermissionDTO);
                response = new XbbResponse<>(userGetDataPermissionVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            } catch (IllegalAccessException | InstantiationException e) {
                LOG.error("/user/maxDataPermission 捕获异常", e);
                response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100001);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 更新助理部门/员工,该接口用于员工列表(组织架构) -> 角色分配逻辑
     */
    @RequestMapping(value = "/updateAssist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String updateAssist(@RequestBody @Valid UserAssistUpdateDTO assistUpdateDTO, BindingResult br) {
        XbbResponse<BaseVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                BaseVO assistAddVO = userService.updateAssist(assistUpdateDTO);
                response = new XbbResponse<>(assistAddVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 添加助理部门/员工,该接口用于员工列表(组织架构) -> 角色分配逻辑
     */
    @RequestMapping(value = "/addAssist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String addAssist(@RequestBody @Valid UserAssistAddDTO assistAddDTO, BindingResult br) {
        XbbResponse<UserAssistAddVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserAssistAddVO assistAddVO = userService.addAssist(assistAddDTO);
                response = new XbbResponse<>(assistAddVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 去除助理部门/员工,该接口用于员工列表(组织架构) -> 角色分配逻辑
     */
    @RequestMapping(value = "/delAssist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String delAssist(@RequestBody @Valid UserAssistDelDTO assistDelDTO, BindingResult br) {
        XbbResponse<UserAssistDelVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserAssistDelVO assistDelVO = userService.delAssist(assistDelDTO);
                response = new XbbResponse<>(assistDelVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 用户列表按字母排序
     * @param userLetterListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/letterList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String tree(@RequestBody @Valid UserLetterListDTO userLetterListDTO, BindingResult br) {
        XbbResponse<UserLetterListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserLetterListVO userLetterListVO = userService.letterList(userLetterListDTO);
                response = new XbbResponse<>(userLetterListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 获取工作交接基础数据
     * 如该员工的客户数，合同数，销售机会数
     */
    @RequestMapping(value = "/workHandover/info", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String workHandoverInfo(@RequestBody @Valid WorkHandoverInfoDTO handoverInfoDTO, BindingResult br) {
        XbbResponse<WorkHandoverInfoVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                WorkHandoverInfoVO handoverInfoVO = userService.getWorkHandoverInfo(handoverInfoDTO);
                response = new XbbResponse<>(handoverInfoVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 执行工作交接
     */
    @RequestMapping(value = "/workHandover/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String workHandoverSave(@RequestBody @Valid WorkHandoverSaveDTO handoverSaveDTO, BindingResult br) {
        XbbResponse<WorkHandoverSaveVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                WorkHandoverSaveVO handoverSaveVO = userService.workHandoverSave(handoverSaveDTO);
                response = new XbbResponse<>(handoverSaveVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     * 获取交接状态
     */
    @RequestMapping(value = "/workHandover/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String workHandoverStatus(@RequestBody @Valid BaseDTO baseDTO, BindingResult br) {
        XbbResponse<WorkHandoverStatusVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                WorkHandoverStatusVO handoverSaveVO = userService.getWorkHandoverStatus(baseDTO);
                response = new XbbResponse<>(handoverSaveVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    @RequestMapping(value = "/permissionModuleDetail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String permissionDetail(@RequestBody @Valid PermissionModuleDetailDTO permissionModuleDetailDTO, BindingResult br) {
        XbbResponse<RoleModuleDetailVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                RoleModuleDetailVO roleModuleDetailVO = userService.permissionModuleDetail(permissionModuleDetailDTO);
                response = new XbbResponse<>(roleModuleDetailVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    @RequestMapping(value = "/permissionAppDetail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String permissionAppDetail(@RequestBody @Valid PermissionAppDetailDTO permissionAppDetailDTO, BindingResult br) {
        XbbResponse<RoleAppDetailVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                RoleAppDetailVO roleAppDetailVO = userService.permissionAppDetail(permissionAppDetailDTO);
                response = new XbbResponse<>(roleAppDetailVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

    /**
     *
     * @Description: 添加常用团队成员
     * @param
     * @return: java.lang.String
     * @Author: shen.yang
     * @Date: 2022/1/24  10:20
    */
    @RequestMapping(value = "/addMembers", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String addMembers(@RequestBody @Valid UserMembersAddDTO userMembersAddDTO, BindingResult br){
        XbbResponse<BaseVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            BaseVO baseVO = userService.addMembers(userMembersAddDTO);
            response = new XbbResponse<>(baseVO);
        }
        return JSON.toJSONString(response);
    }

    /**
     *
     * @Description: 获取团队常用成员
     * @param userMembersGetDTO
     * @param br
     * @return: java.lang.String
     * @Author: shen.yang
     * @Date: 2022/1/25  9:32
    */
    @RequestMapping(value = "/getMembers", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getMembers(@RequestBody @Valid UserMembersGetDTO userMembersGetDTO, BindingResult br){
        XbbResponse<UserMembersVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                UserMembersVO members = userService.getMembers(userMembersGetDTO);
                response = new XbbResponse<>(members);
            } catch (XbbException e) {
            response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response);
    }

}
